package code;

import java.io.IOException;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import constants.Constants;
import data.Data;
import file.Parser;

public class UserItemTestTrain {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {

		String dir = Constants.dir;
		
		String trainFile = dir;// + Constants.trainingFile;
		String testFile = dir;// + Constants.testFile;
		
		Parser parseTrain = new Parser(trainFile);	
		Parser parseTest = new Parser(testFile);	
		
		List<Data> trainData = parseTrain.getList();		
		List<Data> testData = parseTest.getList();
		
		Set<Integer> userSet = new HashSet<Integer>();
		Set<Short> itemSet = new HashSet<Short>();
		
		for(Data data : testData){
			Integer uid = data.uid;
			Short iid = data.iid;
			
			userSet.add(uid);
			itemSet.add(iid);
		}
		
		int count=0;
		
		for(Data data : trainData){
			Integer uid = data.uid;
			Short iid = data.iid;
			
			if(userSet.contains(uid) || itemSet.contains(iid)) {
				count++;
			}
		}
		
		System.out.println("Count:"+count);
		System.out.println("Train size:"+trainData.size());
		System.out.println("Unneccessary:"+(trainData.size()-count));
		System.out.println("Percentage:"+count/(double)trainData.size());
	}

}
